<?php
require_once(MODULESPATH . "core/d.object.class.php");
require_once(MODULESPATH . "finance/dataaccess/d.finance.inc.php");

/**
 * 财经系统数据层财经数据类。
 */
class DFinance extends DObject implements IDFinance{
    /*- IDFinance 接口实现 START -*/
    /*- IInjectEnable 接口实现 START -*/
    /**
     * 设置属性值。
     */
    public function __set($prop, $val){
        $this->$prop = $val;
    }
    /*- IInjectEnable 接口实现 END -*/

    /**
     * 获取证券类型的列表。
     */
    public function getStockTypes(){
        $result = array();
        $sql = "SELECT  `type_code` , `type_name` FROM  `finance_stock_types`";
        try{
            $rows = $this->dao->getData($sql);
            if($rows){
                foreach($rows as $row){
                    array_push($result, array(
                        "code" => $row["type_code"],
                        "name" => $row["type_name"]
                        ));
                }
            }
        }catch(Exception $ex){
        }
        return  $result;
    }
    
    /**
     * 获取证券市场的列表。
     */
    public function getStockMarkets(){
        $result = array();
        $sql = "SELECT  `market_code` ,  `market_name` FROM  `finance_stock_markets`";
        try{
            $rows = $this->dao->getData($sql);
            if($rows){
                foreach($rows as $row){
                    array_push($result, array(
                        "code" => $row["market_code"],
                        "name" => $row["market_name"]
                        ));
                }
            }
        }catch(Exception $ex){
        }
        return  $result;
    }
    
    /**
     * 获取证券交易类型的列表。
     */
    public function getInvestmentTypes(){
        $result = array();
        $sql = "SELECT  `type_code` , `type_name` FROM  `finance_stock_investment_types`";
        try{
            $rows = $this->dao->getData($sql);
            if($rows){
                foreach($rows as $row){
                    array_push($result, array(
                        "code" => $row["type_code"],
                        "name" => $row["type_name"]
                        ));
                }
            }
        }catch(Exception $ex){
        }
        return  $result;
    }
    /*- IDFinance 接口实现 END -*/
}
?>
